package com.ljl.question5;

import java.util.Scanner;

/**
 * 启动类
 *
 * @author ljl
 */
public class Question5Application {
    /**
     * 点的个数
     */
    private static int pointCnt;
    static int[][] points;
    static boolean[] visited;
    static int minDistance = Integer.MAX_VALUE;

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            pointCnt = scanner.nextInt();
            points = new int[pointCnt][2];
            visited = new boolean[pointCnt];
            for (int i = 0; i < pointCnt; i++) {
                points[i][0] = scanner.nextInt();
                points[i][1] = scanner.nextInt();
            }
            dfs(0, 0, 0);
        }
        System.out.println(minDistance);
    }

    /**
     * 当前点，经过的点数，当前路径的总距离
     *
     * @param current  当前点
     * @param count    经过的点数
     * @param distance 总距离
     */
    public static void dfs(int current, int count, int distance) {
        // 如果已经经过了所有点，并且回到了起点，更新最小距离
        if (count == pointCnt && current == 0) {
            minDistance = Math.min(minDistance, distance);
            return;
        }
        // 遍历全部点
        for (int i = 0; i < pointCnt; i++) {
            if (!visited[i]) {
                visited[i] = true;
                int dx = points[current][0] - points[i][0];
                int dy = points[current][1] - points[i][1];
                int newDistance = distance + Math.abs(dx) + Math.abs(dy);
                dfs(i, count + 1, newDistance);
                visited[i] = false;
            }
        }
    }
}
